package edu.xpu.project.record.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import edu.xpu.project.record.entity.AssignBusRecord;

/**
 * @describe 校车派遣记录数据库操作层
 * @author liukang
 * @date 2017年5月13日
 */
@Repository
public interface AssignBusRecordRepository extends JpaRepository<AssignBusRecord, Long>
				, JpaSpecificationExecutor<AssignBusRecord>{
	
	public List<AssignBusRecord> findByStatus(Integer status);
	
	@Query(value="SELECT * "
			+ "FROM ASSIGN_BUSRECORD assign "
			+ "WHERE date_format(assign.create_date,'%Y-%m-%d') = ?2 "
			+ "AND assign.bus_schedule_id = ?1", nativeQuery=true)
	public List<AssignBusRecord> getRecordsByBusScheduleIdAndTime(Long scheduleId, String dateStr);

}
